layui.use('form', function() {
	var form = layui.form;




	form.on('submit(demo2)', function(data){


		if(!checkPhone()){
			return false;
		}
		// email: "1198989760@qq,com"
		// nickname: "zzfgl"
		// password: "zzfgl"
		// sex: "1"
		// status: "on"
		// tel: "17340526901"
		// userImg: "C:\fakepath\5a37515a-04f3-424d-9051-1705ac427c43n_v2a0d5bb13580f4cb68ee4d47101f4fe18.jpg"
		// userName: "zzfgl"
		// var formdata = new FormData($("#add")[0]);

		data.field.userImg=$('#demo1').attr('src');


		$.post($('form').attr("action"),data.field, function (e){

			if (e.result==true) {

				parent.closeLayer(e.msg);
			}else {
				layer.msg('操作失败：' + e.msg, {icon: 2, time: 2000});
			}
		})
		return false;
	})

	form.on('submit(demo1)', function(data) {


		// if(!checkPhone()){
		// 	return false;
		// }

		$.ajax({
			url: $('form').attr("action"),
			type: "POST",
			data: data.field,
			cache: false,
			processData: false,
			contentType: false,
			done: function (e) {

				if (e.result == true) {

					parent.closeLayer(e.msg);
				} else {
					layer.msg('操作失败：' + e.msg, {icon: 2, time: 2000});
				}
			}
		});
	});
	
});